home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1995 October / EnigmA AMIGA RUN 01 (1995)(G.R. Edizioni)(IT)[!][issue 1995-10][Aminet 7].iso / Aminet / comm / fido / jm950618.lha / rexx / checkexists.rexx
OS/2 REXX Batch file  |  1995-04-11  |  2KB  |  71 lines

  1.  /* Checkexists.rexx 
  2.   *
  3.   *  Simple script to demonstrate a few interesting uses of XferQ by
  4.   *  showing how to remove any work nodes in the database that point to files
  5.   *  that no longer exist.
  6.   *
  7.   * Uses xferq.library by David Jones (aa457@freenet.carleton.ca)
  8.   *
  9.   * Russell McOrmond   rmcormon@ccs.carleton.ca aa302@freenet.carleton.ca 
  10.   * FidoNet 1:163/109  Net Support: (613) 230-2282  WPL Support  1:1/139 
  11.   *
  12.   * you must rxlib xferq.library for this script to function correctly.
  13.   *
  14.   * rxlib xferq.library 0 -30 0
  15.   *
  16.   */
  17.  
  18.  Options RESULTS
  19.  Options failat 100
  20.  
  21.  /* Create a stem for all the nodes who have work */
  22.  sitelist=XfqGetSiteList()
  23.  call XfqWalkSession(sitelist,sitearray)
  24.  
  25.  say "There are "sitearray.numentries" sites in the queue"
  26.  
  27.  /* Now we'll iterate through them all */
  28.  do loop = 1 to sitearray.numentries
  29.  
  30.    /* As we loop, we remember that we don't 'own' the sitearray.loop 
  31.       pointer to the address.  Do not do a DROP on that object! */
  32.  
  33.    /* I want full 5-D addresses shown here! */
  34.    addrtags.XQ_Mandatory = 511 /* XQADDR_ANYTHING */
  35.    addrtags.XQ_Optional = 511  /* XQADDR_ANYTHING */
  36.    System = XfqPutAddress(sitearray.loop,addrtags)
  37.   
  38.    /* Create a stem for all the work nodes.  All the stem extensions
  39.       that XfqExamObject understands will be set up! */
  40.    call XfqWalkQueue(sitearray.loop,thestem)
  41.  
  42.    say ""
  43.    say "There are "thestem.NUMENTRIES" files for "System
  44.  
  45.    /* now iterate through all the files */
  46.    do i=1 to thestem.NUMENTRIES
  47.  
  48.      say "sending "thestem.i.NAME" as "thestem.i.ASNAME" at priority "thestem.i.PRI
  49.  
  50.      /* does the full pathname exist? */
  51.      if ~EXISTS(thestem.i.NAME) then do
  52.        say "File does not exist!"
  53.  
  54.        /* NOP - Let's find the work node */
  55.        FINDIT.XQ_NAME = thestem.i.NAME
  56.        FINDIT.XQ_SITE = sitearray.loop
  57.        work = XfqFindWork(FINDIT)
  58.        if(work=NULL) then say "Something is broken!"
  59.        else do
  60.          /* and remove the work from the Queue */
  61.          call XfqRemoveWork(work)
  62.          call XfqDropObject(work)
  63.        end
  64.      end
  65.    end
  66.  end
  67.  /* Drop the sitelist */
  68.  call XfqDropObject(sitelist)
  69.  call XfqClose()
  70.  Exit 0
  71.